package com.prj.ufdm.auth.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.prj.ufdm.auth.enums.AuthRetCodeEnum;
import com.prj.ufdm.core.dto.RetData;
import com.prj.ufdm.core.util.UfdmRequestUtil;

/**
 * 用户名、密码登录注销成功后处理
 * @author Administrator
 */
@Service
public class LogoutSuccessProcess extends SimpleUrlLogoutSuccessHandler{
	
	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,Authentication authentication) throws IOException, ServletException {
		UfdmRequestUtil.addCsrfHeader(response);
		RetData<String> retData = new RetData<>();
		retData.getRetHead().setCode(AuthRetCodeEnum.RET_CODE_0101003.getCode());
		retData.getRetHead().setMessage(AuthRetCodeEnum.RET_CODE_0101003.getMessage());
		response.getWriter().write(JSON.toJSONString(retData));
	}
	
}
